<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    // function handleData(arr, bool = true) {
    //   let sum = arr.reduce((pre, cur) => pre + cur)
    //   return bool ? sum : sum / arr.length
    // }
    // let arr =
    // let handlerData = (arr, bool = true) => bool ? arr.reduce((pre, cur) => pre + cur) : arr.reduce((pre, cur) => pre + cur) / arr.length
    // console.log(handleData(arr, false));

    // console.log(handlerData(arr, false));
    console.log(((arr, bool = true) => bool ? arr.reduce((pre, cur) => pre + cur) : arr.reduce((pre, cur) => pre + cur) / arr.length)([10, 40, 10], false));
  </script>
</body>

</html>